<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="overview-tag">
    <lv-group lvGutter="24px">
        <img src="assets/img/distributed_backup_storage.png" class="overview-img">
        <lv-group lvGutter="8px" lvDirection="vertical">
            <h1 class="vertical-up-text"> {{ clusterName }} </h1>
            <lv-group lvGutter="4px" lvDirection="vertical" *ngIf="!isDecouple; else decoupleStatus">
                <span class="aui-text-label desc-font"> {{ deployType }} </span>
                <span class="aui-link desc-font" (click)="clusterDetail()"> {{ 'system_view_cluster_details_label' | i18n}} </span>
            </lv-group>
        </lv-group>
    </lv-group>
    <lv-group lvGutter="40px" class="overview-tag-right-group" *ngIf="!isDecouple">
        <lv-group lvGutter="4px" lvDirection="vertical">
            <lv-group lvGutter="8px">
                <i class="big-icon" [lv-icon]="errorNodeCount === 0 ? 'lv-icon-popup-success-48' : 'lv-icon-popup-error-48'"></i>
                <span class="error-nodes"> {{ errorNodeCount }} </span>
            </lv-group>
            <span class="aui-text-label desc-font"> {{ 'system_abnormal_node_label' | i18n}} </span>
        </lv-group>
        <div class="vertical-line"></div>
        <lv-group lvGutter="8px" lvDirection="vertical">
            <h1 class="summary-count vertical-up-text">
                {{clusterData?.totalCapacity | capacityCalculateLabel:'1.1-3':unitconst.KB:true}}
            </h1>
            <span class="aui-text-label desc-font"> {{ 'common_total_capacity_label' | i18n}} </span>
        </lv-group>
    </lv-group>
</div>
<div>
    <div class="aui-operation">
        <lv-group>
          <lv-pro-button-group [config]="optsConfig"></lv-pro-button-group>
        </lv-group>
        <lv-group lvGutter="8px">
            <button class="aui-button-icon" lv-button lvSize="auto" (click)="dataTable.fetchData()">
                <i lv-icon="lv-icon-refresh" [lvColorState]="true"></i>
            </button>
        </lv-group>
    </div>
    <div class="list-container">
        <lv-pro-table #dataTable [config]="tableConfig" [data]="tableData"></lv-pro-table>
    </div>
</div>

<ng-template #clusterStatusTpl let-item>
    <aui-status [value]="item.status" type="DistributedClusterStatus"></aui-status>
</ng-template>

<ng-template #clusterRoleTpl let-item>
    <span> {{ clusterRole(item) }} </span>
</ng-template>

<ng-template #decoupleStatus>
    <lv-group lvGutter="8px">
        <i [lv-icon]="errorNodeCount === 0 ? 'lv-icon-popup-success-48' : 'lv-icon-popup-error-48'"></i>
        <span class="desc-font"> {{ 'system_abnormal_node_label' | i18n}} : {{ errorNodeCount }} </span>
    </lv-group>
</ng-template>
